#include <bits/stdc++.h>
// 2025/04/04
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, c, dp[51][51][2], w[51], dist[51];


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> c;
    for (int i = 1; i <= n; i++)
        cin >> dist[i] >> w[i];
    for (int i = 1; i <= n; i++)
        w[i] += w[i - 1];
    memset(dp, 0x3f, sizeof(dp));
    dp[c][c][0] = dp[c][c][1] = 0;
    for (int len = 2; len <= n; len++)
        for (int l = 1, r = len; r <= n; l++, r++)  
            dp[l][r][0] = min(dp[l + 1][r][0] + (dist[l + 1] - dist[l]) * (w[n] - w[r] + w[l]), dp[l + 1][r][1] + (dist[r] - dist[l]) * (w[n] - w[r] + w[l])), dp[l][r][1] = min(dp[l][r - 1][0] + (dist[r] - dist[l]) * (w[n] - w[r - 1] + w[l - 1]), dp[l][r - 1][1] + (dist[r] - dist[r - 1]) * (w[n] - w[r - 1] + w[l - 1]));
    cout << min(dp[1][n][0], dp[1][n][1]) << endl;
    return 0;
}